<div class="problemindexholder" problemindex="C">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     C. Eleventh Birthday
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     2 seconds
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     512 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     It is Borya's eleventh birthday, and he has got a great present:
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     cards with numbers. The
     <span class="tex-span">
      <i>
       i
      </i>
     </span>
     -th card has the number
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
     </span>
     written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers
     <span class="tex-span">
      1
     </span>
     ,
     <span class="tex-span">
      31
     </span>
     , and
     <span class="tex-span">
      12
     </span>
     , and he puts them in a row in this order, he would get a number
     <span class="tex-span">
      13112
     </span>
     .
    </p>
    <p>
     He is only 11, but he already knows that there are
     <span class="tex-span">
      <i>
       n
      </i>
      !
     </span>
     ways to put his cards in a row. But today is a special day, so he is only interested in such ways that the resulting big number is divisible by eleven. So, the way from the previous paragraph is good, because
     <span class="tex-span">
      13112 = 1192 × 11
     </span>
     , but if he puts the cards in the following order:
     <span class="tex-span">
      31
     </span>
     ,
     <span class="tex-span">
      1
     </span>
     ,
     <span class="tex-span">
      12
     </span>
     , he would get a number
     <span class="tex-span">
      31112
     </span>
     , it is not divisible by
     <span class="tex-span">
      11
     </span>
     , so this way is not good for Borya. Help Borya to find out how many good ways to put the cards are there.
    </p>
    <p>
     Borya considers all cards different, even if some of them contain the same number. For example, if Borya has two cards with 1 on it, there are two good ways.
    </p>
    <p>
     Help Borya, find the number of good ways to put the cards. This number can be large, so output it modulo
     <span class="tex-span">
      998244353
     </span>
     .
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     Input data contains multiple test cases. The first line of the input data contains an integer
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     — the number of test cases (
     <span class="tex-span">
      1 ≤
      <i>
       t
      </i>
      ≤ 100
     </span>
     ). The descriptions of test cases follow.
    </p>
    <p>
     Each test is described by two lines.
    </p>
    <p>
     The first line contains an integer
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 2000
     </span>
     ) — the number of cards in Borya's present.
    </p>
    <p>
     The second line contains
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     integers
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ) — numbers written on the cards.
    </p>
    <p>
     It is guaranteed that the total number of cards in all tests of one input data doesn't exceed
     <span class="tex-span">
      2000
     </span>
     .
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     For each test case output one line: the number of ways to put the cards to the table so that the resulting big number was divisible by 11, print the number modulo
     <span class="tex-span">
      998244353
     </span>
     .
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Example
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>4<br/>2<br/>1 1<br/>3<br/>1 31 12<br/>3<br/>12345 67 84<br/>9<br/>1 2 3 4 5 6 7 8 9<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>2<br/>2<br/>2<br/>31680<br/></pre>
     </div>
    </div>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
